package demo;


class Login{
    public String name="abc";
    public String num="12345";
    public void loginInfo(String userName,String userNum)
            throws UserNameException,UserNumberException{
        if(!this.name.equals(userName))
        {
            throw new UserNameException("用户名异常");

        }
         if (!this.num.equals(userNum)){

            throw  new UserNumberException("用户密码异常");

        }
        System.out.println("登陆成功");
    }
}
public class U {
    public static void main(String[] args) {
        Login login=new Login();
        try {
            login.loginInfo("abcd","12345");
        }
        catch (UserNameException e){
            System.out.println("捕捉到了UserNameException");
            e.printStackTrace();
        }catch (UserNumberException e){
            System.out.println("捕捉到了UserNumberException");
            e.printStackTrace();

        }
        finally {
            System.out.println();
        }
    }

}
